/** 返回 */
const renderBoolOpenDom = (value: string | null) => {
  let text: string = '--';
  let color: string = '';
  if (value == '0') {
    text = '否';
    color = '#ff4d4f';
  } else if (value == '1') {
    text = '是';
    color = '#52c41a';
  } else if (value == '2') {
    text = '必须';
    color = '#096dd9';
  }
  return (
    <span
      style={{
        color,
      }}
    >
      {text ? text : '--'}
    </span>
  );
};

/** 采购办法 */
const renderSupplyWayDom = (value: string | null) => {
  let text: string = '--';
  let color: string = '';
  if (value == '0') {
    text = '月度计划';
    color = '#faad14';
  } else if (value == '1') {
    text = '零星采购';
    color = '#096dd9';
  } else if (value == '2') {
    text = '实验平台';
    color = '#9254de';
  }
  return (
    <span
      style={{
        color,
      }}
    >
      {text ? text : '--'}
    </span>
  );
};

/** 采购规则 */
const renderRuleStyleDom = (value: string | null) => {
  let text: string = '--';
  let color: string = '';
  if (value == '0') {
    text = '前开后开';
    color = '#9254de';
  } else if (value == '1') {
    text = '前开后闭';
    color = '#eb2f96';
  } else if (value == '2') {
    text = '前闭后开';
    color = '#531dab';
  } else if (value == '3') {
    text = '前闭后闭';
    color = '#388f0d';
  }
  return (
    <span
      style={{
        color,
      }}
    >
      {text ? text : '--'}
    </span>
  );
};

/** 预算费用 */
const renderPlanPriceDom = (value: string | null, priceMin: string | any, priceMax: string | any) => {
  let text: string = '--';
  if (value == '0') {
    text = `(${priceMin || 0}，${priceMax || 0})`;
  } else if (value == '1') {
    text = `(${priceMin || 0}，${priceMax || 0}]`;
  } else if (value == '2') {
    text = `[${priceMin || 0}，${priceMax || 0})`;
  } else if (value == '3') {
    text = `[${priceMin || 0}，${priceMax || 0}]`;
  }
  return <span>{text ? text : '--'}</span>;
};

export { renderBoolOpenDom, renderSupplyWayDom, renderRuleStyleDom, renderPlanPriceDom };
